package com.hd.trans.offline;

import org.jetbrains.annotations.NotNull;

import io.reactivex.observers.DisposableObserver;

public class OfflineDisposableObserver<T> extends DisposableObserver<T> {

    private final CallBack callBack;

    public interface CallBack {
        void onNext(Object bean);

        void onError(Throwable e);

        void onComplete();
    }

    public OfflineDisposableObserver(CallBack callBack) {
        this.callBack = callBack;
    }

    @Override
    public void onNext(@NotNull T tDataResponse) {

        try {
            if (tDataResponse != null) {
                callBack.onNext(tDataResponse);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    public void onError(@NotNull Throwable e) {
        callBack.onError(e);
    }

    @Override
    public void onComplete() {
        callBack.onComplete();
    }
}
